/*  1:   */package com.github.binarywang.demo.wechat.service.impl;
/*  2:   */
/*  3:   */import com.github.binarywang.demo.wechat.dao.CourseMapper;
/*  4:   */import com.github.binarywang.demo.wechat.dao.FavoriteMapper;
/*  5:   */import com.github.binarywang.demo.wechat.dao.UserMapper;
/*  6:   */import com.github.binarywang.demo.wechat.model.Course;
/*  7:   */import com.github.binarywang.demo.wechat.model.Favorite;
/*  8:   */import com.github.binarywang.demo.wechat.model.FavoriteKey;
/*  9:   */import com.github.binarywang.demo.wechat.model.User;
/* 10:   */import com.github.binarywang.demo.wechat.model.vo.FavoriteVO;
/* 11:   */import com.github.binarywang.demo.wechat.service.WxFavoriteService;
/* 12:   */import com.github.binarywang.demo.wechat.utils.Page;
/* 13:   */import java.util.ArrayList;
/* 14:   */import java.util.List;
/* 15:   */import org.springframework.beans.BeanUtils;
/* 16:   */import org.springframework.beans.factory.annotation.Autowired;
/* 17:   */import org.springframework.stereotype.Service;
/* 18:   */
/* 19:   */@Service("wxFavoriteService")
/* 20:   */public class WxFavoriteServiceImpl
/* 21:   */  implements WxFavoriteService
/* 22:   */{
/* 23:   */  @Autowired
/* 24:   */  private FavoriteMapper favoriteMapper;
/* 25:   */  @Autowired
/* 26:   */  private UserMapper userMapper;
/* 27:   */  @Autowired
/* 28:   */  private CourseMapper courseMapper;
/* 29:   */  
/* 30:   */  public int insert(Favorite favorite)
/* 31:   */  {
/* 32:32 */    return this.favoriteMapper.insert(favorite);
/* 33:   */  }
/* 34:   */  
/* 35:   */  public List<FavoriteVO> findByCourseId(Integer courseId, Integer start) {
/* 36:36 */    List<FavoriteVO> resultList = new ArrayList();
/* 37:37 */    List<Favorite> sourceList = this.favoriteMapper.selectByCourseId(courseId);
/* 38:38 */    for (Favorite favorite : sourceList) {
/* 39:39 */      FavoriteVO favoriteVO = new FavoriteVO();
/* 40:40 */      BeanUtils.copyProperties(favorite, favoriteVO);
/* 41:41 */      User user = this.userMapper.selectByPrimaryKey(favorite.getOpenId());
/* 42:42 */      favoriteVO.setUser(user);
/* 43:43 */      Course course = this.courseMapper.selectByPrimaryKey(favorite.getCourseId());
/* 44:44 */      favoriteVO.setCourse(course);
/* 45:45 */      resultList.add(favoriteVO);
/* 46:   */    }
/* 47:47 */    resultList = Page.getCurrentPage(resultList, start);
/* 48:48 */    return resultList;
/* 49:   */  }
/* 50:   */  
/* 51:   */  public List<FavoriteVO> findByOpenId(String openId, Integer start) {
/* 52:52 */    List<FavoriteVO> resultList = new ArrayList();
/* 53:53 */    List<Favorite> sourceList = this.favoriteMapper.selectByOpenId(openId);
/* 54:54 */    for (Favorite favorite : sourceList) {
/* 55:55 */      FavoriteVO favoriteVO = new FavoriteVO();
/* 56:56 */      BeanUtils.copyProperties(favorite, favoriteVO);
/* 57:57 */      User user = this.userMapper.selectByPrimaryKey(favorite.getOpenId());
/* 58:58 */      favoriteVO.setUser(user);
/* 59:59 */      Course course = this.courseMapper.selectByPrimaryKey(favorite.getCourseId());
/* 60:60 */      favoriteVO.setCourse(course);
/* 61:61 */      resultList.add(favoriteVO);
/* 62:   */    }
/* 63:63 */    resultList = Page.getCurrentPage(resultList, start);
/* 64:64 */    return resultList;
/* 65:   */  }
/* 66:   */  
/* 67:   */  public int delete(FavoriteKey key) {
/* 68:68 */    return this.favoriteMapper.deleteByPrimaryKey(key);
/* 69:   */  }
/* 70:   */}


/* Location:           C:\Users\Windows\Desktop\wx\BOOT-INF\classes\
 * Qualified Name:     com.github.binarywang.demo.wechat.service.impl.WxFavoriteServiceImpl
 * JD-Core Version:    0.7.0-SNAPSHOT-20130630
 */